﻿using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace uTrade.Controls
{
    public class CrossLine : DrawingRegion
    {
        private Pen LineStyle = new Pen(Brushes.Black, 1)
        {
            DashStyle = DashStyles.DashDotDot
        };

        protected override void OnRender(DrawingContext dc)
        {
            Point point = Mouse.GetPosition(this);

            var xoffset = (int)(point.X) + 0.5;
            var yoffset = (int)(point.Y) + 0.5;

            if (yoffset < base.ChartEndY)
            {
                //vertical
                dc.DrawLine(LineStyle, new Point(xoffset, base.ChartStartY), new Point(xoffset, base.ChartEndY));
                //horizontal
                dc.DrawLine(LineStyle, new Point(base.ChartStartX, yoffset), new Point(base.ChartEndX, yoffset));
            }
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            this.InvalidateVisual();
        }
    }
}